import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mirac
 * Date: 2025-10-19
 * Time: 23:56
 */
public class Solution {
    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        //将宝石保存起来
        for (int i = 0; i < jewels.length(); i++) {
            set.add(jewels.charAt(i));
        }

        //记录石头中宝石的数量
        int count = 0;

        //判断石头中的宝石
        for (int i = 0; i < stones.length(); i++) {
            if (set.contains(stones.charAt(i))) {
                count++;
            }
        }

        return count;
    }
}
